﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using NENAData.Factory;
using NENAData.LINQ;

namespace NENAData.NENAMember.Account
{
    public class Password
    {
        private static MembershipDataContext GetMembershipDB()
        {
            var x = new SQLMembership();
            return x.GetMembershipDB();
        }
        public static string Generate(int intLength)
        {
            string strPassword = GetPassword();

            do
            {
                strPassword += GetPassword();
            } while (strPassword.Length < intLength);
            //return "space";
            return strPassword;
        }
        static string GetPassword()
        {
            var oRandom = new Random();
            int intRandom = oRandom.Next(1, 6975);

            MembershipDataContext db = GetMembershipDB();
            var password = (from pwd in db.Passwords
                                 where pwd.Password_ID == intRandom
                                 select pwd).FirstOrDefault();

            return password.Password_Value;
        }
    }
}
